package zdream.pmfield.stage.message;

import java.util.Objects;

import zdream.pmfield.stage.object.FoeActor;

/**
 * @author Zdream
 * @date 2023-11-27
 * @since 0.0.1
 */
public class FoeReceiveDamageMessage extends StageMessage {
	public final FoeActor foe;
	public int damage;
	public int hpFrom, hpTo;
	public int shieldFrom, shieldTo;
	public String title = "";

	public FoeReceiveDamageMessage(FoeActor foe) {
		this.foe = Objects.requireNonNull(foe);
		this.type = StageMessageType.REPORT;
	}

	public FoeReceiveDamageMessage withDamage(int damage) {
		this.damage = damage;
		return this;
	}

	public FoeReceiveDamageMessage withHpFrom(FoeActor foe) {
		this.hpFrom = foe.getCurrentHp();
		this.shieldFrom = foe.currentShield;
		return this;
	}

	public FoeReceiveDamageMessage withHpTo(FoeActor foe) {
		this.hpTo = foe.getCurrentHp();
		this.shieldTo = foe.currentShield;
		return this;
	}

	public FoeReceiveDamageMessage withTitle(String title) {
		this.title = Objects.requireNonNull(title);
		return this;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder(64);
		builder.append("[RD]").append(' ');
		foe.appendStringWithoutHp(builder);
		builder.append(' ');
		builder.append("受到了").append(' ').append(damage).append(' ').append("伤害").append(',').append(' ');
		builder.append("HP").append(' ').append(hpFrom).append(' ').append("->").append(' ').append(hpTo);
		builder.append(',').append(' ');
		builder.append("护盾").append(' ').append(shieldFrom).append(' ').append("->").append(' ').append(shieldTo);

		return builder.toString();
	}
}
